package com.group.project.hrms.controller;

import com.group.project.hrms.entity.HolidayList;
import com.group.project.hrms.entity.ResultEntity.ResultEntity;
import com.group.project.hrms.service.IHolidayListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;


@Controller
public class HolidayListController {

    @Autowired
    private IHolidayListService iHolidayListService;


    /**
     * 该方法接收前端请求，查询所有节假日名称信息并返回给前端页面
     * @param request http请求
     * @return 标准返回值对象
     */
    @RequestMapping("/basic/getHolidayList")
    @ResponseBody
    public ResultEntity getHolidayList(HttpServletRequest request){
        ResultEntity resultEntity = new ResultEntity();
        try{
            resultEntity.setCode("S");
            resultEntity.setMsg("Success");
            resultEntity.setDataList(iHolidayListService.selectAllHolidayList());
        }catch (Exception e){
            resultEntity.setCode("F");
            resultEntity.setMsg("请求数据库失败");
        }
        return resultEntity;
    }

    /**
     * 该方法接收前端传来的创建用户自定义的假日名称并做持久化操作
     * @param map 用户自定义的假日名称信息
     * @param request http请求
     * @return 标准返回值对象
     */
    @RequestMapping("/basic/insertHolidayList")
    @ResponseBody
    public ResultEntity insertHolidayList(@RequestBody Map map, HttpServletRequest request){
        ResultEntity resultEntity = new ResultEntity();
        resultEntity.setCode("F");
        resultEntity.setMsg("未完待续");
        return resultEntity;
    }

    /**
     *
     * @param map
     * @param request request http请求
     * @return 标准返回值对象
     */
    @RequestMapping("/basic/deleteHolidayList")
    @ResponseBody
    public ResultEntity deleteHolidayList(@RequestBody Map map, HttpServletRequest request){
        ResultEntity resultEntity = new ResultEntity();
        resultEntity.setCode("F");
        resultEntity.setMsg("未完待续");
        return resultEntity;
    }


}
